import http from "@/http";

// 获取订单设置
export const orderSettingListAPI = (): RES<orderSettingModel> =>
  http.get("orderSetting/1");

// 提交订单修改设置
export const orderSettingParams = (
  params: orderSettingModel
): RES<orderSettingModel> => http.post("/orderSetting/update/1", params);

// /returnApply/delete 批量删除退货申请
export const ApiApplyDelete = (ids: number[]): RES<number> =>
  http.post(`/returnApply/delete?ids=${ids}`);

// 获取订单列表数据
export const orderLIstAPI = (
  params: orderParams
): RES<ITableResult<IOrderList>> => http.get(`/order/list`, { params });

// 分页查询全部退货原因列表
export const returnReasonListApi = (params: IOrderReason): RES<OrderReturn> =>
  http.get(
    `/returnReason/list?pageNum=${params.pageNum}&pageSize=${params.pageSize}`
  );

// 添加退货原因
export const createReturnReasonApi = (
  params: ICreateReturnReason
): RES<OrderReturn> => http.post("/returnReason/create", params);

// 批量删除退货原因
export const deleteReturnReasonApi = (params: number[]): RES<OrderReturn> =>
  http.post(`/returnReason/delete?ids=${params}`);

// 获取单个退货原因详情信息,编辑用
export const editReturnReasonApi = (id: number): RES<List> =>
  http.get(`/returnReason/${id}`);

// 修改退货原因
export const updateReturnReasonApi = (params: IEditReturnReason): RES<List> =>
  http.post(`/returnReason/update/${params.id}`, params);

// 分页退货申请 /returnApply/list
export const ApiReturnApply = (
  params: IReturnApplyParams
): RES<ITableResult<IReturnApplyList>> =>
  http.get(`/returnApply/list`, { params });
// /returnApply/{id} 获取退货申请详情
export const ApiReturnApplyAll = (id: number): RES<IReturnApplyList> =>
  http.get(`/returnApply/${id}`);

// 关闭订单状态
export const orderOperationCloseAPI = (
  array: number[],
  note: string
): RES<number> =>
  http.post(`/order/update/close?ids=${array.join(",")}&note=${note}`);
// 删除订单
export const orderOperationDelAPI = (array: number[]): RES<number> =>
  http.post(`/order/delete?ids=${array.join(",")}`);
// 批量发货
export const orderOperationDeliveryAPI = (
  deliveryParamList: number[]
): RES<number> => http.post("/order/update/delivery", deliveryParamList);

//  获取订单详情
export const getOrderDetailsAPI = (id: number): RES<IOrderDetailsModel> =>
  http.get(`/order/${id}`);
// /order/update/note 备注订单
export const updateNoteAPI = (
  id: number,
  note: string,
  status: number
): RES<number> =>
  http.post(`/order/update/note?id=${id}&note=${note}&status=${status}`);
